package com.vcc.core.derive.converter.cardOrder;

import cn.idev.excel.converters.Converter;
import cn.idev.excel.enums.CellDataTypeEnum;
import cn.idev.excel.metadata.GlobalConfiguration;
import cn.idev.excel.metadata.data.ReadCellData;
import cn.idev.excel.metadata.data.WriteCellData;
import cn.idev.excel.metadata.property.ExcelContentProperty;

public class OrderTypeConverter implements Converter<String> {

    private static String typeToString(String status) {
        return switch (status) {
            //OPEN|RECHARGE|WITHDRAW|BLOCK|UNBLOCK|CLOSE
            case "OPEN" -> "开卡";
            case "RECHARGE" -> "充值";
            case "WITHDRAW" -> "转出";
            case "BLOCK" -> "冻结";
            case "UNBLOCK" -> "解冻";
            case "CLOSE" -> "销卡";
            default -> "未知";
        };
    }

    @Override
    public Class<String> supportJavaTypeKey() {
        return String.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }


    @Override
    public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        return null;
    }


    @Override
    public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        return new WriteCellData<>(typeToString(value));
    }
}

